package net.dreamlu.qa.interceptor;

import net.dreamlu.qa.model.User;

import com.jfinal.aop.Interceptor;
import com.jfinal.core.ActionInvocation;

/**
 * 对用户登录的拦截
 * @author chunmeng.lu
 *
 */
public class UserInterceptor implements Interceptor {
	public void intercept(ActionInvocation ai) {
		if(ai.getController().getSessionAttr("user") == null){
			ai.getController().keepModel(User.class);
			ai.getController().redirect("login", true);
		}else {
			ai.invoke();
		}
	}
}